def factorial(n):
    print("factorial called with n = " + str(n))
    if n == 0:
        return 1
    else:
        res = n * factorial(n-1)
        print("Intermediate result for factorial(" + str(n) + ") : " + str(res))
        return res
    
print(factorial(9))